package cn.xfdzx.android.apps.shop.fragment.type.presenter;

import cn.xfdzx.android.apps.shop.base.BasePresenterImp;
import cn.xfdzx.android.apps.shop.base.NetCallBackImpl;
import cn.xfdzx.android.apps.shop.bean.CategoryAllBeen;
import cn.xfdzx.android.apps.shop.bean.ConfirmGoodBeen;
import cn.xfdzx.android.apps.shop.bean.HomeSearchXFDGoodBeen;
import cn.xfdzx.android.apps.shop.fragment.type.contract.MarketClassificationContract;
import cn.xfdzx.android.apps.shop.fragment.type.model.MarketClassificationModel;
import cn.xfdzx.android.apps.shop.fragment.type.request.AddCart;
import cn.xfdzx.android.apps.shop.fragment.type.request.CateAll;

public class MarketClassificationPresenter extends BasePresenterImp<MarketClassificationContract.View, MarketClassificationContract.Model> implements MarketClassificationContract.Presenter {
    @Override
    public MarketClassificationContract.Model createModel() {
        return new MarketClassificationModel();
    }

    @Override
    public void getClassoficationData(String status) {
        mView.showLoading();
        mModel.getClassoficationData(status, new NetCallBackImpl<CategoryAllBeen>(mView) {
            @Override
            public void onSuccess(CategoryAllBeen categoryAllBeen) {
                mView.getSuccessData(categoryAllBeen);
            }

            @Override
            public void onFailure(String reason) {
                mView.hideLoading();
            }
        });
    }

    @Override
    public void getListAll(CateAll cateAll) {
        mView.showLoading();
        mModel.getListAll(cateAll, new NetCallBackImpl<HomeSearchXFDGoodBeen>(mView) {
            @Override
            public void onSuccess(HomeSearchXFDGoodBeen homeSearchXFDGoodBeen) {
                mView.getListGoodsSuccess(homeSearchXFDGoodBeen);
            }

            @Override
            public void onFailure(String reason) {
                mView.hideLoading();
                mView.getOnFail(reason);
            }
        });
    }

    @Override
    public void addCart(AddCart addCart ,int p) {

        mView.showLoading();

        mModel.addCart(addCart, new NetCallBackImpl<ConfirmGoodBeen>(mView) {
            @Override
            public void onSuccess(ConfirmGoodBeen confirmGoodBeen) {
                mView.addCarSuccess(confirmGoodBeen,p);
            }

            @Override
            public void onFailure(String reason) {
                mView.hideLoading();
                mView.getOnFail(reason);
            }
        });
    }
}
